﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ResourceLoadBalancer.WebServices.Contracts.Data;
using ResourceLoadBalancer.WebServices.Clients.Helpers;
using System.Net;

namespace ResourceLoadBalancer.Client
{
    public class FileScanner
    {
        IList<ResourceDataContract> resources = null;
        IList<ResourceURIDataContract> resourcesURI = null;
        protected ResourceLoadBalancerServiceClientHelper serviceClient = null;
        protected string hostName = null;
        protected string queueName = null;
        protected string scannedPath = null;
        public FileScanner()
        {
            resources = new List<ResourceDataContract>();
            resourcesURI = new List<ResourceURIDataContract>();
            serviceClient = new ResourceLoadBalancerServiceClientHelper();
            hostName = Dns.GetHostName();
        }

        public IList<ResourceDataContract> Resources
        {
            get { return resources; }
            set { resources = value; }
        }

        public IList<ResourceURIDataContract> ResourcesURI
        {
            get { return resourcesURI; }
            set { resourcesURI = value; }
        }

        public ResourceLoadBalancerServiceClientHelper ServiceClient
        {
            get { return serviceClient; }
            set { serviceClient = value; }
        }

        public void ConfigureQueuing(string queueType, string queueName)
        {
            try
            {
                serviceClient.ConfigureQueuing(hostName, queueType, queueName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        public void CleanResourceURIs(string path)
        {
            scannedPath = path;
            try
            {
                serviceClient.CleanResourceURIs(hostName, scannedPath);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

        //private void GetFiles(string directory)
        //{
 
        //}

        
    }


}
